#include <sys/stat.h>
#include <fcntl.h>
#include <semaphore.h>
#include <cstring>
#include <cstdlib>
#include <unistd.h>
#include <cstdio>

int main(){
    sem_t* semfd=sem_open("/ymbxsem",O_CREAT,0666,1);
    sem_t* semfd2=sem_open("/ymbxsem2",O_CREAT,0666,0);
    if(semfd==SEM_FAILED){
        perror("sem_open error");
        exit(1);
    }
    while(1){
        sem_wait(semfd);
        printf("server: receive message\n");
        sleep(3);
        sem_post(semfd2);
        break;
    }

    sem_close(semfd);
    sem_close(semfd2);
    sem_unlink("/ymbxsem2");
    sem_unlink("/ymbxsem");
    return 0;
}